import Request from '@/common/Request';
import {ApiMaster} from '@/common/apiMaster';

const api = (p) => {
	return '/api/user/' + p;
};
export const UserApi = {
	/**
	 * 用户注册
	 * @param data
	 * @returns {Promise<AxiosResponse<any>>}
	 */
	create(data) {
		return Request.post(api('create'), data)
	},
	/**
	 * 用户登陆
	 * @param data
	 * @returns {Promise<AxiosResponse<any>>}
	 */
	auth(data) {
		return Request.post(api('auth'), data)
	},
	/**
	 * 获取用户菜单
	 * @returns {Promise<AxiosResponse<any>>}
	 */
	menu() {
		return Request.get(api('menu'))
	},
	admin: new ApiMaster('/api/backstage/forums/user'),
	roles: new ApiMaster('/api/backstage/forums/user/roles'),
}

export default UserApi;